package com.lanchetech.dao;

import com.lanchetech.bean.request.PageReq;
import com.lanchetech.bean.response.SpuResp;
import com.lanchetech.bean.vo.FlashSaleSpuItemVO;
import com.lanchetech.bean.vo.FlashSaleSpuVO;
import com.lanchetech.entity.FlashSaleSpu;
import java.util.Collection;import java.util.Date;import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface FlashSaleSpuMapper {
    int deleteByPrimaryKey(Long id);

    int insert(FlashSaleSpu record);

    int insertSelective(FlashSaleSpu record);

    FlashSaleSpu selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(FlashSaleSpu record);

    int updateByPrimaryKey(FlashSaleSpu record);

    int updateBatch(List<FlashSaleSpu> list);

    int updateBatchSelective(List<FlashSaleSpu> list);

    int batchInsert(@Param("list") List<FlashSaleSpu> list);

    List<FlashSaleSpu> findAllByActivityId(@Param("activityId") Long activityId);

    int deleteByActivityIdAndSpuList(@Param("activityId") Long activityId, @Param("list") long[] list);

    Long countByActivityId(@Param("activityId") Long activityId);

    List<FlashSaleSpuItemVO> findAllPageForUser(PageReq req);

    List<FlashSaleSpuItemVO> findAllPageForUser2(PageReq req);

    FlashSaleSpu findOneByActivityIdAndSpuId(@Param("activityId") Long activityId, @Param("spuId") Long spuId);

    FlashSaleSpu findOneByActivityIdAndShopIdAndStatusOrderBySortsDesc(@Param("activityId") Long activityId, @Param("shopId") Long shopId, @Param("status") Byte status);

    int updateDeletedAndStatusByActivityId(@Param("updatedDeleted") Byte updatedDeleted, @Param("updatedStatus") Byte updatedStatus, @Param("activityId") Long activityId);

    List<FlashSaleSpu> findAllByIdIn(@Param("idCollection") Collection<Long> idCollection);

    int updateSalesAndUpdatedAtByActivityIdAndSpuId(@Param("updatedSales") Integer updatedSales, @Param("updatedUpdatedAt") Date updatedUpdatedAt, @Param("activityId") Long activityId, @Param("spuId") Long spuId);

    int refundSalesAndUpdatedAtByActivityIdAndSpuId(@Param("updatedSales") Integer updatedSales, @Param("updatedUpdatedAt") Date updatedUpdatedAt, @Param("activityId") Long activityId, @Param("spuId") Long spuId);

    /**
     * 通过活动ids和商家id查询所有秒杀商品
     * @param activityIds
     * @param tenantId
     * @return
     */
    List<FlashSaleSpuVO> findAllByActivityIdsAndTenantId(@Param("activityIds")List<Long> activityIds, @Param("tenantId") Long tenantId);
}